package com.ydw.xstream;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.ydw.model.Person;

/**
 * Created by ydw on 2017/7/5.
 */
public class XstreamTest {
    public static void main(String[] args) {
        Person person = new Person();
        person.setAge(18);
        person.setName("ydw");
        person.setId(1L);

        XStream xStream = new XStream(new DomDriver());
        xStream.alias("person",Person.class);
        String xml = xStream.toXML(person);
        System.out.println(xml);

        Person fromXML = (Person) xStream.fromXML(xml);
        System.out.println(fromXML);
    }
}
